package com.hu.zhcc.shiro.service.Lixueseng520;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.LxsExerciseDAO;
import com.hu.zhcc.shiro.entity.bo.Lixueseng520.LxsExercise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ExerciseServiceImpl implements ExerciseService {
    @Autowired
    private LxsExerciseDAO dao;


    @Override
    public Page<LxsExercise> findExerciseByPrimary(Map map, Integer offset, Integer limit) {
        PageHelper.startPage(offset,limit);
        List<LxsExercise> exerciseList = dao.findExerciseByPrimary(map);
        for (LxsExercise lxsExercise : exerciseList) {
            System.out.println(lxsExercise);
        }
        PageInfo<LxsExercise> info = new PageInfo<>(exerciseList);
        return new Page<>(info.getTotal(),exerciseList);
    }

    @Override
    public int insertSelective(LxsExercise record) {
        return dao.insertSelective(record);
    }

    @Override
    public int updateByPrimaryKeySelective(LxsExercise record) {
        return dao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return dao.deleteByPrimaryKey(id);
    }
}
